//头文件宏
#ifndef TM1638_EVENT_SOURCE_H_
#define TM1638_EVENT_SOURCE_H_
//包含文件
#include "esp_event.h"
#include "esp_event_loop.h"
#include "esp_event_base.h"
#include "esp_timer.h"




// 事件源的声明


//事件库声明
ESP_EVENT_DECLARE_BASE(TM1638_EVENTS);	// TM1638事件库的声明


//TM1638事件id枚举声明
enum {
    TM1638_ERR_EVENT,        //错误
    TM1638_INIT_EVENT,       //初始化
    TM1638_LED_UP_EVENT,	 //开灯
    TM1638_LED_OFF_EVENT,    //关灯
    TM1638_KEY_DOWN_EVENT,   //按键按下
    TM1638_KEY_UP_EVENT,     //按键弹起
    TM1638_NIXIE_TUBE_INPUT, //数码管输入
    TM1638_DEL_EVENT         //销毁
    
    //可以声明多个 事件ID
};
//代码段

typedef struct {
    //esp_event_loop_args_t   tm1638_event_loop_args;
    esp_event_loop_handle_t tm1638_event_loop_handle;
    uint8_t     init;
    uint8_t     led;
    uint8_t     key;
    char     num[8];
}tm1638_drive;


//esp_err_t tm1638_drive_create(tm1638_drive * drive,esp_event_handler_t handler);
tm1638_drive * tm1638_drive_malloc(esp_event_handler_t handler);
uint8_t tm1638_drive_led_get(tm1638_drive * drive,uint8_t no);
uint8_t tm1638_drive_led_up(tm1638_drive * drive,uint8_t no);
uint8_t tm1638_drive_led_off(tm1638_drive * drive,uint8_t no);
uint8_t tm1638_drive_key_get(tm1638_drive * drive);
uint8_t tm1638_drive_num_input(tm1638_drive * drive,uint8_t add,u_char data);
esp_err_t tm1638_drive_del(tm1638_drive ** drive);




#endif // #ifndef EVENT_SOURCE_H_